package com.ghpt.controller;
import com.ghpt.pojo.DiYuan;
import com.ghpt.service.DiYuanService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping("/diyuan")
public class DiYuanController {
    private final DiYuanService diYuanService;

    public DiYuanController(DiYuanService diYuanService) {
        this.diYuanService = diYuanService;
    }
    @GetMapping("/{id}")
    public DiYuan getDiYuanById(@PathVariable Long id) {
        System.out.println("结果是"+diYuanService.findDiYuanById(id));
        return diYuanService.findDiYuanById(id);
    }
    @PutMapping
    public int updateDiYuan(@RequestBody DiYuan diYuan) {
        return diYuanService.updateById(diYuan);
    }
}
